
package ui.activity.poscontrol.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import net.ck.hzq.R;

import java.util.ArrayList;
import java.util.List;

import base.BaseViewHolder;
import base.SuperBaseAdapter;
import ui.activity.poscontrol.ChangeBackDetailAct;
import ui.activity.poscontrol.beanmodel.ChangeBankSelectListBean;


/**
 *POS查询列表适配器
 * Created by chenjian on 19/2/27
 */
public class ChangeBackAdapter extends SuperBaseAdapter<ChangeBankSelectListBean.RecordsBean> {

    Context mContext;
    List<ChangeBankSelectListBean.RecordsBean> mData=new ArrayList<>();
    int msign;//0我发起的1我接受的
    public ChangeBackAdapter(Context context ,List<ChangeBankSelectListBean.RecordsBean> data,int sign) {
        super(context,data);
        mContext = context;
        msign = sign;
        mData = data;
    }
    public void refresh() {
    }

    @Override
    protected void convert(BaseViewHolder holder, final ChangeBankSelectListBean.RecordsBean item, final int position) {
        holder.setText(R.id.backamount,item.getSourceAmount()+"元");
        holder.setText(R.id.changeamount,item.getNewAmount()+"元");
        if(msign==0) {
            switch (item.getStatus()) {
                case 1:
                    holder.setText(R.id.status, "待处理");
                    holder.setTextColor(R.id.status,mContext.getResources().getColor(R.color.blue_0ca6f0));
                    break;
                case 2:
                    holder.setText(R.id.status, "已同意");
                    holder.setTextColor(R.id.status,mContext.getResources().getColor(R.color.green_189633));
                    break;
                case 3:
                    holder.setText(R.id.status, "已拒绝");
                    holder.setTextColor(R.id.status,mContext.getResources().getColor(R.color.red_fe3333));
                    break;
                case 4:
                    holder.setText(R.id.status, "已过期");
                    holder.setTextColor(R.id.status,mContext.getResources().getColor(R.color.tc_666666));
                    break;
            }
        }else{
            holder.setOnClickListener(R.id.grouplayout, new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent (mContext, ChangeBackDetailAct.class);
                    intent.putExtra("sn",item.getId()+"");
                    intent.putExtra("sign",msign);
                    mContext.startActivity(intent);
                }
            });
            switch (item.getStatus()) {
                case 1:
                    holder.setText(R.id.status, "待处理");
                    holder.setBackgroundResource(R.id.status,R.drawable.bg_changebackblue);
                    holder.setTextColor(R.id.status,mContext.getResources().getColor(R.color.colorWhite));
                    break;
                case 2:
                    holder.setText(R.id.status, "已同意");
                    holder.setBackgroundResource(R.id.status,R.drawable.bg_changebackgreen);
                    holder.setTextColor(R.id.status,mContext.getResources().getColor(R.color.colorWhite));
                    break;
                case 3:
                    holder.setText(R.id.status, "已拒绝");
                    holder.setBackgroundResource(R.id.status,R.drawable.bg_changebackred);
                    holder.setTextColor(R.id.status,mContext.getResources().getColor(R.color.colorWhite));
                    break;
                case 4:
                    holder.setText(R.id.status, "已过期");
                    holder.setBackgroundResource(R.id.status,R.drawable.bg_changebackgrey);
                    holder.setTextColor(R.id.status,mContext.getResources().getColor(R.color.colorWhite));
                    break;
            }
        }
        holder.setText(R.id.postype,item.getCategory());
        holder.setText(R.id.time,item.getUpdateTime());
        holder.setText(R.id.snnum,item.getSn());
    }



    @Override
    protected int getItemViewLayoutId(int position, ChangeBankSelectListBean.RecordsBean item) {
        return R.layout.item_changeback_list;
    }

}
